﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class BasicBase_Duty_DutyAddType2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Bind();
    }
    private void Bind()
    {
        this.dptDepartment.DataSource = Yipusoft.Common.BLL.CodeItem.GetList(" Left(ItemID,4)='ZBLB'");
        this.dptDepartment.DataTextField = "ItemName";
        this.dptDepartment.DataValueField = "ItemID";
        this.dptDepartment.DataBind();
        this.dptDepartment.SelectedValue = "ZBLB1"+Yipusoft.Account.BLL.User.GetUser(User.Identity.Name).DepartmentID.Substring(4, 1)+"00";           
        
        this.dptDepartment.Enabled = false;
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Yipusoft.Duty.Model.DutyTypeInfo info = new Yipusoft.Duty.Model.DutyTypeInfo();
        info.ItemID = dptDepartment.SelectedValue;
        info.Num = int.Parse(txtNum.Text.Trim());
        info.Show = "0";
        info.DTName = txtName.Text.Trim();
        info.DutyType = (Yipusoft.Duty.BLL.DutyType.GetID() + 1).ToString("D2");
        info.DepartmentID = Yipusoft.Account.BLL.User.GetUser(User.Identity.Name).DepartmentID;
        info.Mode = "0";
        int result= Yipusoft.Duty.BLL.DutyType.Add(info);
        if (result > 0)
        {
            lblpromt.Text = "添加成功";
            txtName.Text = "";
            txtNum.Text = "";
        }
        else
            lblpromt.Text = "添加失败";
       
    }
}
